using Oracle.ManagedDataAccess.Client;
using Oracle.ManagedDataAccess.Types;
using OracleInternal.I18N;

namespace OracleInternal.ServiceObjects
{
	internal class OraXmlBlobWithText
	{
		internal OracleBlob m_xmlBlob;

		internal int m_csid;

		internal bool m_bGetValue;

		internal bool m_bGetIsEmpty;

		internal string m_strValue = string.Empty;

		internal bool m_bIsEmpty = true;

		internal bool IsEmpty
		{
			get
			{
				if (!m_bGetIsEmpty)
				{
					m_bIsEmpty = m_xmlBlob.IsEmpty;
				}
				return m_bIsEmpty;
			}
		}

		internal string Value
		{
			get
			{
				if (!m_bGetValue)
				{
					byte[] value = m_xmlBlob.Value;
					if (value != null && value.Length != 0)
					{
						Conv instance = Conv.GetInstance(m_csid);
						m_strValue = instance.ConvertBytesToString(value, 0, value.Length);
					}
					else
					{
						m_strValue = string.Empty;
					}
					m_bIsEmpty = (string.IsNullOrEmpty(m_strValue) ? true : false);
					m_bGetIsEmpty = true;
					m_bGetValue = true;
				}
				return m_strValue;
			}
		}

		internal OraXmlBlobWithText(OracleConnection conn, byte[] lobLocator, int csid)
		{
			m_xmlBlob = new OracleBlob(conn, lobLocator);
			m_csid = csid;
		}

		internal OraXmlBlobWithText(OracleBlob blob, int csid)
		{
			m_xmlBlob = blob;
			m_csid = csid;
		}

		internal OraXmlBlobWithText Clone()
		{
			return new OraXmlBlobWithText((OracleBlob)m_xmlBlob.Clone(), m_csid);
		}

		internal void Dispose()
		{
			if (m_xmlBlob != null)
			{
				m_xmlBlob.Dispose();
				m_xmlBlob = null;
			}
		}
	}
}
